import yaml

from web_practice.wework_po.page_object.base_page import BasePage


class LoginPage(BasePage):
    _Base_URL = "https://work.weixin.qq.com/wework_admin/frame"
    def login(self):
        """登录"""
        # 2.2. cookie 添加到当前打开的浏览器当中
        with open("../datas/cookies.yaml") as f:
            cookies = yaml.safe_load(f)
        # print(cookies)
        for cookie in cookies:
            self.driver.add_cookie(cookie)

        # 2.3. 刷新页面，实现自动登录
        self.driver.refresh()
        from web_practice.wework_po.page_object.index_page import IndexPage
        return IndexPage(self.driver)
